Skip to content

Add support for multi module project in runtime #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 28, 2014

Conversation

tmandke
Copy link

@tmandke tmandke commented Nov 25, 2014

Fixes #54
So the issue I discovered is that if the first statement for a thread belongs to the parent project the measurements file gets created in the parent project. This file is used to write measurements for both the parent and child project.

My solution to this was to make the writer and the ids into maps that take the data dir into account.

@tmandke
Copy link
Author

tmandke commented Nov 25, 2014

So I realized my solution has one issue. But I am not sure how to address it. (It may be ok to not worry about it)

    1. Take for example the following class in the parent project.
class Foo  {
  def foo = "foo"
}
    1. The following class in the child project
class Bar extends Foo {
  def bar = "bar"
}
    1. The following tests in the child project
class BarSpec extends FlatSpec with Matchers with OptionValues with Inside with Inspectors {
  it should "return foo" in {
    new Bar().foo shouldEqual "foo"
  }
  it should "return bar" in {
    new Bar().bar shouldEqual "bar"
  }
}
    1. You run sbt clean coverage test and the parent project now has 0% coverage since it finished quickly and when it finished it did not have any measurements files to look at in the parent project.
    1. Now add a test file to core like so
class FooSpec extends FlatSpec with Matchers with OptionValues with Inside with Inspectors {
  "this test" should "kill time" in {
    Thread.sleep(10000)
  }
}
    1. Again you run sbt clean coverage test and the parent project now has 100% coverage since it finished after child project tests and has the measurements files for the parent project from the child project's test run.

So, This results in a non deterministic result in coverage depending on how long the tests will take to run for each project. Also, this behavior where parent project gets some coverage on statements when covered from a child project may not be something that is desirable. And may cause some confusion.

@sksamuel
Copy link
Member

This is a great fix thank you, and to address the non-deterministic behaviour, we might be able to do something in the sbt plugin that runs a report step last.

sksamuel added a commit that referenced this pull request Nov 28, 2014
Add support for multi module project in runtime
@sksamuel sksamuel merged commit 7e6e67e into scoverage:master Nov 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect coverage report for multi-module maven builds
2 participants